package com.zhoukun.cloud.service;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author zhoukun 86547462@qq.com
 * @version 1.0
 * @date 2020/10/30 2:01
 */
@EnableBinding(Source.class)//定义消息推送管道
public class MessageProducImpl implements MessageProduc{

    @Resource
    private MessageChannel output;//消息发送管道

    public void send() {
        String uuid= UUID.randomUUID().toString();
        output.send(MessageBuilder.withPayload(uuid).build());
        System.out.println("8801发布了"+uuid);
    }
}
